<template>
  <div class="box11">
    <v-chart :option="getOption()"></v-chart>
  </div>
</template>

<script setup lang="ts">
const getOption = () => {
  return {
    title: {},
    xAxis: {
      show: false,
      type: "category",
    },
    yAxis: {
      show: false,
    },
    series: {
      type: "bar",
      data: props.orderUserTrend,
      //每一个柱状图的颜色设置
      itemStyle: {
        color(item: any) {
          let arr = [
            "red",
            "orange",
            "yellow",
            "green",
            "cyan",
            "blue",
            "purple",
            "red",
            "orange",
            "yellow",
            "green",
            "cyan",
            "blue",
            "purple",
          ];
          return arr[item.dataIndex];
        },
      },
    },
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
      show: true,
      backgroundColor: {
        type: "linear",
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [
          {
            offset: 0,
            color: "yellowgreen", // 0% 处的颜色
          },
          {
            offset: 1,
            color: "cyan", // 100% 处的颜色
          },
        ],
        global: false, // 缺省为 false
      },
    },
    tooltip: {
      confine: true,
      textStyle: {
        color: "yellowgreen",
      },
      //提示框位置设置
      position: function (point, params, dom, rect, size) {
        // 固定在顶部
        return [point[0], "10%"];
      },
      //指示器插件
      axisPointer: {
        show: true,
        type: "line",
      },
    },
  };
};
//接受父组件传递过来的数据
let props = defineProps(['orderUserTrend'])
</script>

<style scoped>
.box11 {
  width: 100%;
  height: 100%;
}
</style>